from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ES
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webdriver import WebElement
timea=8
class Base():
    def __init__(self,driver:WebDriver):
        self.driver = driver
    def sleep(self,x):
        import time
        time.sleep(x)
    def wait_element(self,loc,timeout=None) ->WebElement:
        timeout = timea if timeout is None else timeout
        wiat=WebDriverWait(self.driver,timeout=timeout)
        return wiat.until(ES.element_to_be_clickable(loc))
    def wait_visibility(self,loc,timeout=None) ->WebElement:
        timeout = timea if timeout is None else timeout
        wiat=WebDriverWait(self.driver,timeout=timeout)
        return wiat.until(ES.visibility_of_element_located(loc))
    def open_url(self,url):
        self.driver.get(url)
    def click(self,loc):
        wait_click=self.wait_element(loc)
        wait_click.click()
    def fill(self,loc,info):
        self.wait_visibility(loc).send_keys(info)


